﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace MLY
{
  public partial class MainMenu : System.Web.UI.UserControl
  {
    protected void Page_Load(object sender, EventArgs e)
    {
        LoadDemoStyle();        
    }

    public void LoadDemoStyle()
    {

        //switch ((string)Session["DemoStage"])
        //{
        //    case "none":
        //        Literal1.CssClass = "demostophighlight";
        //        Literal10.CssClass = "demostophighlight";
        //        Literal5.CssClass = "demostophighlight";
        //        AlertsLink.CssClass = "demostophighlight";
        //        Literal7.CssClass = "demostophighlight";
        //        break;
        //    case "DataTransfer":
        //        if ((string)Session["DemoSubStage"] == "1")
        //        {
        //            Literal1.CssClass = "demohighlight";
        //            Literal10.CssClass = "demostophighlight";
        //            Literal5.CssClass = "demostophighlight";
        //            AlertsLink.CssClass = "demostophighlight";
        //            Literal7.CssClass = "demohighlight";
        //        }
        //        else
        //        {
        //            Literal1.CssClass = "demostophighlight";
        //            Literal10.CssClass = "demostophighlight";
        //            Literal5.CssClass = "demostophighlight";
        //            AlertsLink.CssClass = "demostophighlight";
        //            Literal7.CssClass = "demostophighlight";
        //        }
        //        break;
        //    case "Reports":
        //        if ((string)Session["DemoSubStage"] == "1")
        //        {
        //            Literal1.CssClass = "demohighlight";
        //            Literal10.CssClass = "demostophighlight";
        //            Literal5.CssClass = "demohighlight";
        //            AlertsLink.CssClass = "demostophighlight";
        //            Literal7.CssClass = "demostophighlight";
        //        }
        //        else
        //        {
        //            Literal1.CssClass = "demostophighlight";
        //            Literal10.CssClass = "demostophighlight";
        //            Literal5.CssClass = "demostophighlight";
        //            AlertsLink.CssClass = "demostophighlight";
        //            Literal7.CssClass = "demostophighlight";
        //        }
        //        break;
        //    case "Inventory":
        //        if ((string)Session["DemoSubStage"] == "1")
        //        {
        //            Literal1.CssClass = "demohighlight";
        //            Literal10.CssClass = "demohighlight";
        //            Literal5.CssClass = "demostophighlight";
        //            AlertsLink.CssClass = "demostophighlight";
        //            Literal7.CssClass = "demostophighlight";
        //        }
        //        else
        //        {
        //            Literal1.CssClass = "demostophighlight";
        //            Literal10.CssClass = "demostophighlight";
        //            Literal5.CssClass = "demostophighlight";
        //            AlertsLink.CssClass = "demostophighlight";
        //            Literal7.CssClass = "demostophighlight";
        //        }
        //        break;
        //    case "Inventory2":
        //        if ((string)Session["DemoSubStage"] == "1")
        //        {
        //            Literal1.CssClass = "demohighlight";
        //            Literal10.CssClass = "demohighlight";
        //            Literal5.CssClass = "demostophighlight";
        //            AlertsLink.CssClass = "demostophighlight";
        //            Literal7.CssClass = "demostophighlight";
        //        }
        //        else
        //        {
        //            Literal1.CssClass = "demostophighlight";
        //            Literal10.CssClass = "demostophighlight";
        //            Literal5.CssClass = "demostophighlight";
        //            AlertsLink.CssClass = "demostophighlight";
        //            Literal7.CssClass = "demostophighlight";
        //        }
        //        break;
        //    case "Language":
        //        Literal1.CssClass = "demostophighlight";
        //        Literal10.CssClass = "demostophighlight";
        //        Literal5.CssClass = "demostophighlight";
        //        AlertsLink.CssClass = "demostophighlight";
        //        Literal7.CssClass = "demostophighlight";
        //        break;
        //    case "Alerts":
        //        if ((string)Session["DemoSubStage"] == "1")
        //        {
        //            Literal1.CssClass = "demostophighlight";
        //            Literal10.CssClass = "demostophighlight";
        //            Literal5.CssClass = "demostophighlight";
        //            AlertsLink.CssClass = "demohighlight";
        //            Literal7.CssClass = "demostophighlight";
        //        }
        //        else if ((string)Session["DemoSubStage"] == "4")
        //        {
        //            Literal1.CssClass = "demohighlight";
        //            Literal10.CssClass = "demohighlight";
        //            Literal5.CssClass = "demostophighlight";
        //            AlertsLink.CssClass = "demostophighlight";
        //            Literal7.CssClass = "demostophighlight";
        //        }
        //        else
        //        {
        //            Literal1.CssClass = "demostophighlight";
        //            Literal10.CssClass = "demostophighlight";
        //            Literal5.CssClass = "demostophighlight";
        //            AlertsLink.CssClass = "demostophighlight";
        //            Literal7.CssClass = "demostophighlight";
        //        }
        //        break;
        //    default:
        //        Literal1.CssClass = "demostophighlight";
        //        Literal10.CssClass = "demostophighlight";
        //        Literal5.CssClass = "demostophighlight";
        //        AlertsLink.CssClass = "demostophighlight";
        //        Literal7.CssClass = "demostophighlight";
        //        break;

        //}

        //if (((string)Session["DemoCode"] == "1") || ((string)Session["DemoCode"] == "10"))
        //{
        //    Literal1.CssClass = "demohighlight";
        //    Literal10.CssClass = "demohighlight";
        //    Literal5.CssClass = "demostophighlight";
        //    AlertsLink.CssClass = "demostophighlight";
        //    Literal7.CssClass = "demostophighlight";
        //}
        //else if (((string)Session["DemoCode"] == "4") || ((string)Session["DemoCode"] == "4.5") || ((string)Session["DemoCode"] == "5"))
        //{
        //    Literal1.CssClass = "demohighlight";
        //    Literal5.CssClass = "demohighlight";
        //    Literal10.CssClass = "demostophighlight";
        //    AlertsLink.CssClass = "demostophighlight";
        //    Literal7.CssClass = "demostophighlight";
        //}
        //else if ((string)Session["DemoCode"] == "6")
        //{
        //    Session["DemoCode"] = "6.1";
        //}
        //else if ((string)Session["DemoCode"] == "8")
        //{
        //    Session["DemoCode"] = "8.1";
        //}
        //else if (((string)Session["DemoCode"] == "6.1") || ((string)Session["DemoCode"] == "8.1") || ((string)Session["DemoCode"] == "6"))
        //{
        //    Literal1.CssClass = "demostophighlight";
        //    Literal5.CssClass = "demostophighlight";
        //    Literal10.CssClass = "demostophighlight";
        //    AlertsLink.CssClass = "demohighlight";
        //    Literal7.CssClass = "demostophighlight";
        //}
        //else if (((string)Session["DemoCode"] == "12") ||
        //         ((string)Session["DemoCode"] == "12.1") ||
        //         ((string)Session["DemoCode"] == "11.1"))
        //{
        //    Literal1.CssClass = "demohighlight";
        //    Literal5.CssClass = "demostophighlight";
        //    Literal10.CssClass = "demostophighlight";
        //    AlertsLink.CssClass = "demostophighlight";
        //    Literal7.CssClass = "demohighlight";
        //}
        //else 
        //{
        //    Literal1.CssClass = "demostophighlight";
        //    Literal10.CssClass = "demostophighlight";
        //    Literal5.CssClass = "demostophighlight";
        //    AlertsLink.CssClass = "demostophighlight";
        //    Literal7.CssClass = "demostophighlight";
        //}
    }
    public static bool rowEnabled(int rowNum)
    {
      Bll.clsOrganization org = null;
      _userRoleId = Bll.clsUser.CurrentUserRoleId;
      if (Bll.clsUser.CurrentUserOrganizationId != -1)
      {
        org = new MLY.Bll.clsOrganization(Bll.clsUser.CurrentUserOrganizationId);
      }

      switch (_userRoleId)
      {
        case (int)Bll.clsUser.enumRoleId.None:
          if (rowNum == 400 || rowNum == 500)
            return true;
          else
            return false;

        case (int)Bll.clsUser.enumRoleId.Role10_Operation:
          if (rowNum == 100 || (rowNum == 200 && org != null && (bool)org.Data.IsClient) ||
              (rowNum == 300 && org != null && (bool)org.Data.IsContractor) || rowNum == 400
              || rowNum == 500 || rowNum == 600 || rowNum == 700 || rowNum == 800 ||
              rowNum == 210 || rowNum == 310 || rowNum == 220 || rowNum == 320 || rowNum == 230 || rowNum == 330 || rowNum == 240)
              return true;
          else
              return false;

        case (int)Bll.clsUser.enumRoleId.Role20_Management:
          if (rowNum == 100 || (rowNum == 200 && org != null && (bool)org.Data.IsClient) ||
              (rowNum == 300 && org != null && (bool)org.Data.IsContractor) || rowNum == 400 || rowNum == 800 
              || rowNum == 500 || rowNum == 700 || rowNum == 230 || rowNum == 330)
            return true;
          else
            return false;

        case (int)Bll.clsUser.enumRoleId.Role30_IT:
          if (rowNum == 100 || (rowNum == 200 && org != null && (bool)org.Data.IsClient) ||
              (rowNum == 300 && org != null && (bool)org.Data.IsContractor) || rowNum == 400 || rowNum == 800
              || rowNum == 500 || rowNum == 600 || rowNum == 700 || rowNum == 230 || rowNum == 330 || rowNum == 240 || rowNum == 340)
            return true;
          else
            return false;

        case (int)Bll.clsUser.enumRoleId.Role40_CustomerAdmin:
          if (((rowNum == 100 || (rowNum == 200 && org != null && (bool)org.Data.IsClient) ||
                    (rowNum == 300 && org != null && (bool)org.Data.IsContractor) || rowNum == 400
                    || rowNum == 500 || rowNum == 600 || rowNum == 700 || rowNum == 230 || rowNum == 330 || rowNum == 240 || rowNum == 340))
              || ((rowNum == 100 || (rowNum == 200 && org != null && (bool)org.Data.IsClient) ||
              (rowNum == 300 && org != null && (bool)org.Data.IsContractor) || rowNum == 400
              || rowNum == 500 || rowNum == 600 || rowNum == 700 || rowNum == 800 ||
              rowNum == 210 || rowNum == 310 || rowNum == 220 || rowNum == 320 || rowNum == 230 ||
              rowNum == 330)))
            return true;
          return false;

        case (int)Bll.clsUser.enumRoleId.Role60_Admin:
          return true;
        default:
          return false;
      }
    }

    private static int _userRoleId = -1;

    protected bool UserLoggedIn()
    {
        return (SessParam.UserId != -1);
    }
    protected bool IsClient()
    {
        return SessParam.IsClient;
    }
    protected void Literal12_Click(object sender, EventArgs e)
    {
      Utils.logOff();
    }
  }
}